package com.atguigu.lease.web.admin.service.impl;

import com.atguigu.lease.module.entity.ApartmentFeeValue;
import com.atguigu.lease.module.entity.FeeValue;
import com.atguigu.lease.web.admin.mapper.ApartmentFeeValueMapper;
import com.atguigu.lease.web.admin.mapper.FeeValueMapper;
import com.atguigu.lease.web.admin.service.ApartmentFeeValueService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class ApartmentFeeValueServiceImpl extends ServiceImpl<ApartmentFeeValueMapper, ApartmentFeeValue> implements ApartmentFeeValueService {

    @Autowired
    private FeeValueMapper feeValueMapper;
    @Override
    public List<FeeValue> getApartmentFeeValueListByApartmentId(Long id) {
        //1.根据id值获取公寓跟杂费的关系信息表 因为有entity类 所以可以使用原生api
//        List<ApartmentFeeValue> apartmentFeeValueList = super.list(new LambdaQueryWrapper<ApartmentFeeValue>().eq(ApartmentFeeValue::getApartmentId, id));
        //2.获取feeValueList
//        List<FeeValue> feeValueList = feeValueMapper.selectList(new LambdaQueryWrapper<FeeValue>().in(FeeValue::getId, apartmentFeeValueList.stream().map(ApartmentFeeValue::getFeeValueId).collect(Collectors.toList())));
//        return feeValueList;
        return feeValueMapper.getFeeValueList(id);
    }
}
